package timberman.core;

import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;

public class Debug {
	public static final boolean DEBUG = true;
	public static final String TAG = "vpoint";
	public static int DEPTH = 2;

	public static void log(Object ob) {
		if (DEBUG) {
			if (Gdx.app.getType() == ApplicationType.Android) {
				DEPTH = 3;
			} else {
				DEPTH = 2;
			}
			String message = ob == null ? "Object is null" : ob.toString();
			String fullClassName = Thread.currentThread().getStackTrace()[DEPTH]
					.getClassName();
			String className = fullClassName.substring(fullClassName
					.lastIndexOf(".") + 1);
			String methodName = Thread.currentThread().getStackTrace()[DEPTH]
					.getMethodName();
			int lineNumber = Thread.currentThread().getStackTrace()[DEPTH]
					.getLineNumber();

			Gdx.app.log(TAG, className + "." + methodName + "():" + lineNumber
					+ ":" + message);
		}
	}

	static long time;

	public static void startWatch() {
		// TODO Auto-generated method stub
		time = System.currentTimeMillis();
	}

	public static void stopWatch(String message) {
		log(message + ": " + (System.currentTimeMillis() - time));
	}
}
